package com.byron.action;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.byron.model.User;
import com.byron.service.UserService;
import com.opensymphony.xwork2.ActionSupport;

@Controller
@Scope("prototype")
public class LoginAction extends ActionSupport {

    private static final long serialVersionUID = 1L;

    private String password;
    
    private String username;
    
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    @Autowired
    private UserService userService;
    @Override
    public String execute() throws Exception {
//        userService.findUserByName("1212");
        return SUCCESS;
    }
    
    public void login(){
        User user = new User();
        user.setAddress("12121");
        user.setName(username);
        user.setPassword(password);
        userService.save(user);
        System.out.println("loginAction调用成功……");
        System.out.println("helloworld login");
    }
}
